var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "buyId",
			name : "采购单号"
		}, {
			colkey : "fillingDate",
			name : "日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
				
		}, {
			colkey : "userId",
			name : "申请人"
		},{
			colkey : "state",
			name : "状态",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==0 || data=="0"){
					return "默认";
				}else if (data==1 || data=="1"){
					return "已删除";
				}else if (data==2 || data=="2"){
					return "已验收";
				}else if (data==3 || data=="3"){
					return "已进仓";
				}else if (data==4 || data=="4"){
					return "已退货";
				}
			}
			
		}],
		jsonUrl : rootPath + '/purchase/purchaseRequest_findByPageDetails.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#details").click("click", function() {
		editAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "详情",
		type : 2,
		area : [ "1200px", "100%" ],
		content : rootPath + '/purchase/purchase_metalsbom_details.shtml?buyId=' + cbox
	});
}

